<%--
  Created by IntelliJ IDEA.
  User: 86187
  Date: 2021/10/21
  Time: 10:51
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="resource/bootstrap4/css/bootstrap.css">
    <script src="resource/js/jquery-3.2.1.js"></script>
    <script src="resource/bootstrap-treeview/js/bootstrap-treeview.js"></script>
    <script src="resource/bootstrap4/js/bootstrap.js"></script>
    <script src="resource/My97DatePicker/WdatePicker.js"></script>
    <title>列表</title>
    <script>
        function upFile(obj){
            var formdate = new FormData();
            formdate.append("file",obj[0].file);
            $.ajax({
                type:"post",
                url:"/upFile",
                data:formdate,
                processData:false,
                contentType:false,
                success:function (url){
                    if(null!=url){
                        $("#pic").empty();
                        $("#pic").append("<img src='"+url+"' width='120px' height='120px'>");
                        $("#pic").append("<input type='hidden' name='fhFile' value='"+url+"'>");
                    }
                }
            })

        }

        var i = 1;
        function zjh(){
            $("#trr").append('<tr>'+
                '<td><input type="text" name="goodsList['+i+'].cNum"></td>'+
                '<td><input type="text" name="goodsList['+i+'].cName"></td>'+
                '<td><input type="text" name="goodsList['+i+'].cQu"></td>'+
                '<td><input type="text" name="goodsList['+i+'].cTion"></td>'+
                '<td><input type="text" name="goodsList['+i+'].wlName"></td>'+
                '<td><input type="text" name="goodsList['+i+'].xsPrice"  onblur="zong('+i+')"></td>'+
                '<td><input type="text" name="goodsList['+i+'].num" onblur="zong('+i+')"></td>'+
                '<td><input type="text" name="goodsList['+i+'].money" id="c" onkeyup="zje()"></td>'+
                '<td><input type="text" name="goodsList['+i+'].shAddress"></td>'+
                '<td><input type="text" name="goodsList['+i+'].orShou"></td>'+
                '<td><input type="text" name="goodsList['+i+'].mark"></td>'+
                '<td><input type="text" name="goodsList['+i+'].phoneName"></td>'+
                '<td><input type="text" name="goodsList['+i+'].phone"></td>'+
                '</tr>')
            i++;
        }

        function zong(a){
            var nums = $("[name='goodsList["+a+"].num']").val();
            var price = $("[name='goodsList["+a+"].xsPrice']").val();
            $("[name='goodsList["+a+"].money']").val(Number(nums)*Number(price));
            zje();
        }
        var h = 0;
        function zje(){

            $("#c").each(function (){
                h=h+Number(this.value);
            })
            $("[name='fhMoney']").val(Number(h));
        }
    </script>
</head>
<body>
<form action="/add" method="post">
    出库单号:<input type="text" name="outNum" value="${l1}">
    发货单号:<input type="date" name="fhDate">
    发货日期:<input type="file" name="file" onchange="upFile(this)">
    <span id="pic"></span><br>
    制单人工号:<input type="text" name="zdNum" value="${u1.unum}">
    制单人:<input type="text" name="zdName" value="${u1.uname}">
    制单时间:<input type="date" name="zdDate"><br>
    发货总金额:<input type="text" readonly="readonly" name="fhMoney"><br>
    差额:<input type="text" name="khNum">
    发货单号列表:<input type="text" name="fhNum"><br>
    备注:<textarea name="mark"></textarea>
    <input type="button" value="添加行" onclick="zjh()">
    <table class="table">
        <thead>
        <td>仓库编号</td>
        <td>仓库名称</td>
        <td>库区</td>
        <td>库位</td>
        <td>物料名称</td>
        <td>销售单价</td>
        <td>数量</td>
        <td>金额</td>
        <td>收货地址</td>
        <td>是否收货</td>
        <td>备注</td>
        <td>联系人</td>
        <td>联系电话</td>
        <td>操作</td>
        </thead>

        <thead id="trr">
        <tr><td><input type="text" name="goodsList[0].cNum"></td>
            <td><input type="text" name="goodsList[0].cName"></td>
            <td><input type="text" name="goodsList[0].cQu"></td>
            <td><input type="text" name="goodsList[0].cTion"></td>
            <td><input type="text" name="goodsList[0].wlName"></td>
            <td><input type="text" name="goodsList[0].xsPrice" onblur="zong(0)"></td>
            <td><input type="text" name="goodsList[0].num" onblur="zong(0)"></td>
            <td><input type="text" name="goodsList[0].money" id="c" onkeyup="zje()"></td>
            <td><input type="text" name="goodsList[0].shAddress"></td>
            <td><input type="text" name="goodsList[0].orShou"></td>
            <td><input type="text" name="goodsList[0].mark"></td>
            <td><input type="text" name="goodsList[0].phoneName"></td>
            <td><input type="text" name="goodsList[0].phone"></td>
            <td><a>发货</a></td>
        </tr>
        </thead>

    </table><br>
    <input type="submit" value="提交">
</form>

</body>
</html>